#ifndef __PR2000_FUNC_H__
#define __PR2000_FUNC_H__


#include "typedef.h"

#include "pr2000_support.h"
#include "pr2000_table.h"
#include "pr2000_drvcommon.h"

/* I2C function */

int PR2000_SetPage(const int fd, const uint8_t slvAddr, int page);
int PR2000_Read(const int fd, const uint8_t slvAddr, const uint8_t addr, uint8_t *pData);
int PR2000_Write(const int fd, const uint8_t slvAddr, const uint8_t addr, uint8_t Data);
int PR2000_PageRead(const int fd, const uint8_t slvAddr, const int page, const uint8_t addr, uint8_t *pData);
int PR2000_PageWrite(const int fd, const uint8_t slvAddr, const int page, const uint8_t addr, uint8_t Data);
int PR2000_PageReadMaskBit(const int fd, const uint8_t slvAddr, const int page, const uint8_t addr, const uint8_t maskBit, uint8_t *pData);
int PR2000_PageWriteMaskBit(const int fd, const uint8_t slvAddr, const int page, const uint8_t addr, const uint8_t maskBit, const uint8_t Data);
int PR2000_PageReadBurst(const int fd, const uint8_t slvAddr, const int page, const uint8_t addr, const uint8_t length, uint8_t *pData);
int PR2000_PageWriteBurst(const int fd, const uint8_t slvAddr, const int page, const uint8_t addr, const uint8_t length, uint8_t *pData);

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int PR2000_CheckChipID_SWReset(const int i2cFd, const int maxFindSlvNum, uint8_t *pRetFindSlvAddr, uint16_t *pRetChipID, uint8_t *pRetRevID, int *pRetRWVerify);
int PR2000_SetAttrChip(const int i2cFd, const uint8_t slvAddr, const _stAttrChip *pstPr2000AttrChip);
int PR2000_SetAttrGpioPin(const int i2cFd, const uint8_t slvAddr, const _stAttrGpioPin *pstPr2000AttrGpioPin);
int PR2000_SetTableClkPhase(const int i2cFd, const uint8_t slvAddr, const uint8_t dataRate, const uint8_t clkPhaseNum);
int PR2000_SetTableMipiParallel(const int i2cFd, const uint8_t slvAddr, const uint8_t vidOutMode, const uint8_t bStart, const enum _eCameraStandard cameraStandard, const enum _eVideoResolution videoResolution);
int PR2000_SetTableStdResol(const int i2cFd, const uint8_t slvAddr, const enum _eCameraStandard cameraStandard, const enum _eVideoResolution videoResolution);
int PR2000_Initialize(const int i2cFd, const uint8_t slvAddr);

int PR2000_Isr(const int i2cFd, const uint8_t slvAddr, void *pArg);
int PR2000_ReadVidStatusReg(const int i2cFd, const uint8_t slvAddr, _stPR2000_VidStatusReg *pstVidStatusReg);
int PR2000_ReadStdResol(const int i2cFd, const uint8_t slvAddr, const _stPR2000_VidStatusReg *pstVidStatusReg, enum _eCameraStandard *pCameraStandard, enum _eCameraResolution *pCameraResolution, enum _eVideoResolution *pVideoResolution);
int PR2000_GetStdResol(const int i2cFd, const uint8_t slvAddr, _stPR2000_VidStatusReg *pstVidStatusReg, enum _eCameraStandard *pCameraStandard, enum _eCameraResolution *pCameraResolution, enum _eVideoResolution *pVideoResolution, int *pReJudge);
#ifdef SUPPORT_VID
int PR2000_VID_SetChnAttr(const int i2cFd, const uint8_t slvAddr, const _stChnAttr *pstChnAttr);
int PR2000_VID_GetChnAttr(const int i2cFd, const uint8_t slvAddr, _stChnAttr *pstChnAttr);
int PR2000_VID_SetCscAttr(const int i2cFd, const uint8_t slvAddr, const _stCscAttr *pstCscAttr);
int PR2000_VID_GetCscAttr(const int i2cFd, const uint8_t slvAddr, _stCscAttr *pstCscAttr);
int PR2000_VID_SetContrast(const int i2cFd, const uint8_t slvAddr, const _stContrast *pstContrast);
int PR2000_VID_GetContrast(const int i2cFd, const uint8_t slvAddr, _stContrast *pstContrast);
int PR2000_VID_SetBright(const int i2cFd, const uint8_t slvAddr, const _stBright *pstBright);
int PR2000_VID_GetBright(const int i2cFd, const uint8_t slvAddr, _stBright *pstBright);
int PR2000_VID_SetSaturation(const int i2cFd, const uint8_t slvAddr, const _stSaturation *pstSaturation);
int PR2000_VID_GetSaturation(const int i2cFd, const uint8_t slvAddr, _stSaturation *pstSaturation);
int PR2000_VID_SetHue(const int i2cFd, const uint8_t slvAddr, const _stHue *pstHue);
int PR2000_VID_GetHue(const int i2cFd, const uint8_t slvAddr, _stHue *pstHue);
int PR2000_VID_SetSharpness(const int i2cFd, const uint8_t slvAddr, const _stSharpness *pstSharpness);
int PR2000_VID_GetSharpness(const int i2cFd, const uint8_t slvAddr, _stSharpness *pstSharpness);
int PR2000_VID_SetBlank(const int i2cFd, const uint8_t slvAddr, const int bEnable, const int blankColor);
#endif // SUPPORT_VID
int PR2000_GetNovidStatus(const int i2cFd, const uint8_t slvAddr, uint8_t *pStatus);
#ifdef SUPPORT_UTC
int PR2000_UTC_SetTable(const int i2cFd, const uint8_t slvAddr, const enum _eCameraStandard cameraStandard, const enum _eCameraResolution cameraResolution);
int PR2000_UTC_StartRX(const int i2cFd, const uint8_t slvAddr, const int bStart);
int PR2000_UTC_StartTX(const int i2cFd, const uint8_t slvAddr, const int bStart);
int PR2000_UTC_SendData(const int i2cFd, const uint8_t slvAddr, const enum _eCameraStandard cameraStandard, const enum _eCameraResolution cameraResolution, const int dataSize, const uint8_t *pData);
int PR2000_UTC_GetRxAttr(const int i2cFd, const uint8_t slvAddr, _stUTCRxAttr *pstUTCRxAttr);
int PR2000_UTC_GetTxAttr(const int i2cFd, const uint8_t slvAddr, _stUTCTxAttr *pstUTCTxAttr);
int PR2000_UTC_GetHVStartAttr(const int i2cFd, const uint8_t slvAddr, _stUTCHVStartAttr *pstUTCHVStartAttr);
#endif //SUPPORT_UTC
#ifdef SUPPORT_OSG
int PR2000_OSG_WriteSPI(const int i2cFd, const uint8_t slvAddr, const uint32_t addr, const uint32_t dataSize, const uint8_t *pData);
int PR2000_OSG_ReadSPI(const int i2cFd, const uint8_t slvAddr, const uint32_t addr, const uint32_t dataSize, uint8_t *pData);
int PR2000_OSG_ReadSPIFastDual(const int i2cFd, const uint8_t slvAddr, const uint32_t addr, const uint32_t dataSize, uint8_t *pData);
int PR2000_OSG_ReadSPIFastDualIO(const int i2cFd, const uint8_t slvAddr, const uint32_t addr, const uint32_t dataSize, uint8_t *pData);
int PR2000_OSG_EraseSPI(const int i2cFd, const uint8_t slvAddr, const uint32_t addr);
int PR2000_OSG_SetLUTLoc(const int i2cFd, const uint8_t slvAddr, const uint32_t addr);
int PR2000_OSG_SetRLELoc(const int i2cFd, const uint8_t slvAddr, const uint32_t odd_addr, const uint32_t even_addr);
int PR2000_OSG_Display(const int i2cFd, const uint8_t slvAddr, const int bEnable, const uint32_t addr);
int PR2000_OSG_SetTable(const int i2cFd, const uint8_t slvAddr, const enum _eCameraStandard cameraStandard, const enum _eVideoResolution videoResolution);
#endif //SUPPORT_OSG

#ifdef SUPPORT_REG_SAVEDUMP //support pr2000 register save dump.
void PR2000_PRINT_MKTBL(const int i2cFd, const uint8_t slvAddr);
#endif // SUPPORT_REG_SAVEDUMP //support pr2000 register save dump.

#ifdef SUPPORT_FPGA
int PR2000_FPGA_SetTable(const int i2cFd, const uint8_t slvAddr);
#if defined(__HOST_MICOM_SYSTEM__)
void PR2000_FPGA_SetSADDR(uint8_t saddr);
#endif //defined(__HOST_MICOM_SYSTEM__)
#endif //SUPPORT_FPGA
#ifdef SUPPORT_CPLD
int PR2000_CPLD_SetTable(const uint8_t vidOutMode, const uint8_t dataRate);
#endif // SUPPORT_CPLD

#endif // __PR2000_FUNC_H__
